<style scoped lang="scss">
.page{
  background: linear-gradient(136deg, #E6EEFF 0%, #F9FBFF 53%, #FFFFFF 100%);
}
.logo{
  padding-top: 50rpx;
  padding-bottom: 100rpx;
  display: flex;
  align-items: center;
  justify-content: center;

  image{
    max-width: 400rpx;
    max-height: 200rpx;
  }
}
.form-el{
  margin-left: 25rpx;
  margin-right: 25rpx;
  background: #FFFFFF;
  border-radius: 45rpx;
  padding: 70rpx 50rpx;
}

.form-el-list{
  & > view{
    margin-bottom: 44rpx;
    &:last-child{
      margin-bottom: 0;
    }

    & > view{
      &:nth-child(1){
        display: flex;
        align-items: center;
        font-size: 28rpx;
        margin-bottom: 22rpx;
        color: #101012;

        text{
          font-size: 34rpx;
          margin-right: 9rpx;
        }
      }
      &:nth-child(2){
        height: 90rpx;
        background: #F6F8FE;
        border-radius: 45rpx;
      }

    }

  }
}

.text-inp{
  input{
    padding-left: 47rpx;
    padding-right: 47rpx;
    height: 100%;
  }
}
.code-inp{
  display: flex;
  & > view{
    &:nth-child(1){
      flex: 1;
      input{
        padding-left: 47rpx;
        padding-right: 47rpx;
        height: 100%;
      }
    }
    &:nth-child(2){
      width: 200rpx;
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      color: #577BED;
      font-size: 24rpx;

      &::after{
        content: ' ';
        background: #577BED;
        width: 1rpx;
        height: 25rpx;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        left: 0;
      }
    }
  }

}

.form-el-btns{
  display: flex;
  justify-content: space-between;
  font-size: 28rpx;
  margin-top: 33rpx;
  margin-bottom: 92rpx;
  color: #101012;
}
.btn{
  height: 84rpx;
  line-height: 84rpx;
  background: #577BED;
  border-radius: 45rpx;
  margin-left: 34rpx;
  margin-right: 34rpx;
  font-size: 32rpx;
  color: #FFFFFF;
  text-align: center;
  margin-top: 80rpx;
  margin-bottom: 40rpx;
}

.agreement{
  font-size: 24rpx;
  color: #868688;
  text-align: center;
  margin-top: 60rpx;

  text{
    color: #577BED;
  }
}
</style>

<template>
  <view class="page">
    <view class="s-head">
      <h-head bg="transparent">
        注册
      </h-head>
    </view>

    <view class="s-body">
      <scroll-view class="maxh" :scroll-y="true">

        <view class="logo">
          <image mode="aspectFit" src="../../static/images/logo.png" alt="" />
        </view>

        <view class="form-el">

          <view class="form-el-list">

            <view>
              <view>
                <text class="iconfont icon-shouji"></text>帐号
              </view>
              <view class="text-inp">
                <input v-model="form.username" type="text" maxlength="11" placeholder="请输入帐号">
              </view>
            </view>
            <view>
              <view>
                <text class="iconfont icon-mima"></text>密码
              </view>
              <view class="text-inp">
                <input v-model="form.password" type="password" placeholder="请输入密码">
              </view>
            </view>
            <view>
              <view>
                <text class="iconfont icon-wode4"></text>邀请人
              </view>
              <view class="text-inp">
                <input v-model="form.uid" type="password" placeholder="邀请人，没有可不写">
              </view>
            </view>
          </view>
          <view class="form-el-btns">
            <view></view>
            <view @click="utils.redirectToPage('/pages/login/userLogin')">已有帐号？去登录</view>
          </view>
          <view class="btn" @click="sure">
            注册
          </view>

          <view class="agreement">
            注册即代表您已阅读并同意<text @click="utils.gotoPage('/pages/my/agreement?type=1')">《用户协议》</text>与<text @click="utils.gotoPage('/pages/my/agreement?type=2')">《隐私政策》</text>
          </view>
        </view>
      </scroll-view>
    </view>
  </view>
</template>

<script>
let timer
export default {
  components: {
  },
  onLoad(option) {

  },
  onShow() {
  },
  data() {
    return {
      form: {
        username: '',
        password: '',
        uid: '',
      },
    };
  },
  methods: {
    sure() {
      if(!this.form.username) return this.utils.toast('请输入帐号')
      if(!this.form.password) return this.utils.toast('请输入密码')

      this.httpClient.post({
        url: this.APIPath.user.register,
        data: this.form
      }).then(res => {
        this.storage.setToken(res.data.token)
        this.storage.setUserInfo(res.data.info)
        if(this.globalConfig.CHANNEL_ID == 3) {
          this.httpClient.post({
            url: this.APIPath.config.wxMpCodeUrl,
            data: {}
          }).then(res => {
            location.href = res.data
          })
        }else{
          this.utils.replacePage('/pages/index/index')
        }
      })
    },
  },
};
</script>

